package cn.richard.demo.easyrules.tax;

import java.math.BigDecimal;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@Data
public class TaxDto {
	/**
	 * 起征点
	 */
	private final BigDecimal threshold = BigDecimal.valueOf(5000L); 
	
	/**
	 * 五险一金之后的月收入
	 */
	private BigDecimal income; //输入 
	
	/**
	 * 全月应纳税所得额 = income - threshold
	 */
	private BigDecimal incomeShould; //输入1
	
	/**
	 * 税率
	 */
	private BigDecimal taxRate; //匹配
	
	/**
	 * 速算扣除数
	 */
	private BigDecimal quickCalc;
	
	/**
	 * 缴纳金额 = 全月应纳税所得额*税率-速算扣除数
	 */
	private BigDecimal paidResult; //输出

	public TaxDto(BigDecimal income) {
		this.income = income;
		this.incomeShould = income.subtract(this.threshold);
	}
	
	/**
	 * 结果
	 * @return
	 */
	public BigDecimal paidResult() {
		this.paidResult = incomeShould.multiply(taxRate).subtract(quickCalc);
		return this.paidResult;
	}
}
